<?php 

if ($_SERVER['REQUEST_METHOD']=='POST') {

	$user = $_REQUEST['usuario'];
	$pass = $_REQUEST['pass'];
	
	    
	if (!empty($_REQUEST['usuario']) && !empty($_REQUEST['pass']) ) {
		$user = $_REQUEST['usuario'];
		$pass = $_REQUEST['pass'];
	}else {
		$user = "error1";
		$pass = "error2";
	}


	//declare associative array

	$userpass = array(
		'Alumno' => 'alumno123',
		'Profesor' => 'profesor123'
	);


	if ($pass == $userpass[$user]) {
		session_start();
		$_SESSION['username']=$user;
		//include('index.html');
                echo "<center><br><p>¡Bienvenido!</p><p>Seras redireccionado en 2 segundos</p></center>";
                sleep ( 2 );
                if ($user=='Profesor'){                   
                    echo'<script language="javascript">window.location="profesor.php"</script>';                    
                }
                if ($user=='Alumno'){                  
                    echo'<script language="javascript">window.location="alumno.php"</script>';    
                }
		//include 'includes/cabeceralogin.html';

	}
	else {
		include 'includes/cabeceralogin.html';		
		?>
		</div>
		</center>
                <div id='cuerpo'>
                    <?php echo "<center><a>Login incorrecto</a></center>"; ?>
                </div>
		<?php
                include 'includes/footer.php'; 
	}

}
else {

	include 'includes/cabeceralogin.html';
	?> 
	</div>
	</center>
        <div id='cuerpo'></div>
	<?php
        include 'includes/footer.php'; 
}